﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using SystemCenterSoa.DtoModel.SystemManager.ApplyGather;
using SystemCenterSoa.PoModel.SystemManager.ApplyGather;
using SystemCenterSoa.Service.SystemManager.ApplyGather;

namespace SystemCenterSoa.ApiProject.Area.SystemManager.ApplyGather
{
    public class LeaveApplyController : SystemManagerBaseController
    {
        private LeaveApplyService _leaveApplyService;

        public LeaveApplyController(LeaveApplyService leaveApplyService)
        {
            _leaveApplyService = leaveApplyService;
        }
        /// <summary>
        /// 添加申请(请假)
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public bool AddClocking_inApplyFo(Clocking_inApplyFo model)
        {
            return _leaveApplyService.AddClocking_inApplyFo(model);
        }
        [HttpPost]
        public bool GetLeaveApplyAdd(LeaveApplyPo leaveApply)
        {
            return _leaveApplyService.GetLeaveApplyAdd(leaveApply);
        }
        [HttpGet]
        public IActionResult GetLeaveApplyList(int deId, string nian, string yue, int pageIndex, int pageSize)
        {
            try
            {
                var query = _leaveApplyService.GetLeaveApplyList(deId, nian, yue, pageIndex, pageSize);
                var total = query.Count();
                var list = query.OrderBy(t => t.qj_id).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
                return Ok(new { list, total });
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public LeaveApplyPo GetLeaveApplyFan(int id)
        {
            return _leaveApplyService.GetLeaveApplyFan(id);
        }
        [HttpPost]
        public bool GetLeaveApplyUpdate(LeaveApplyPo leaveApply)
        {
            return _leaveApplyService.GetLeaveApplyUpdate(leaveApply);
        }
        [HttpPost]
        public bool GetLeaveApplyDel(string ids)
        {
            return _leaveApplyService.GetLeaveApplyDel(ids);
        }
    }
}
